home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Borland
/
Borland C++ V5.02
/
TPROFEXM.PAK
/
PRIME4.C
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-06
|
582b
|
29 lines
/* Copyright (c) 1990, 1992, Borland International */
#include <stdio.h>
int prime(int n)
{
int i;
if (n % 2 == 0)
return (n==2);
if (n % 3 == 0)
return (n==3);
if (n % 5 == 0)
return (n==5);
for (i=7; i*i <= n; i+=2)
if (n % i == 0)
return 0;
return 1;
}
void main(void)
{
int i, n;
n = 1000;
for (i=2; i<=n; i++)
if (prime(i))
printf("%d\n", i);
}